package com.heima.common.snowflake;

import com.heima.utils.common.SnowflakeIdWorker;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@RefreshScope
public class SnowflakeConfig {


    @Value("${leadnews.worker-id}")
    private long workerId;

    @Value("${leadnews.datacenter-id}")
    private long datacenterId;

    @Bean
    public SnowflakeIdWorker snowflakeIdWorker(){
        return new SnowflakeIdWorker(workerId,datacenterId);
    }

}
